package com.zeng.springcloud.consumer;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.bus.jackson.RemoteApplicationEventScan;
import org.springframework.context.event.EventListener;

/**
 * @author zyb
 * @date 2021-06-06 23:33
 */
@SpringBootApplication
@RemoteApplicationEventScan(basePackageClasses = MyEvent.class)
public class ConsumerService {
    @EventListener(MyEvent.class)
    public void myEventListener(MyEvent myEvent) {
        System.out.println("收到事件！");
        System.out.println(myEvent);
        System.out.println(myEvent.getSource());
    }

    public static void main(String[] args) {
        SpringApplication.run(ConsumerService.class, args);
    }
}
